package com.llkj.qingnianguoxue.adapter;

import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.bean.WeekDateBean;
import com.llkj.qingnianguoxue.util.DateUtils;

import java.util.List;

/**
 * 预约公告适配器
 */
public class BookCourseDateAdapter extends BaseQuickAdapter<WeekDateBean, BaseViewHolder> {

    private int mCurrentPosition;
    public BookCourseDateAdapter(int layoutResId, List<WeekDateBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, WeekDateBean item) {
        baseViewHolder.setText(R.id.tv_week, item.getWeek());
        baseViewHolder.setText(R.id.tv_date, DateUtils.getMonthDay(item.getStart_time()));

        LinearLayout tvState = baseViewHolder.getView(R.id.ll_root);
        if(mCurrentPosition==baseViewHolder.getLayoutPosition()){
            tvState.setSelected(true);
        }else{
            tvState.setSelected(false);
        }
    }

    public void setSelectPosition(int position){
        mCurrentPosition = position;
        notifyDataSetChanged();
    }
}
